home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16773 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: prairienet.org!sjmccaug
  2. From: sjmccaug@prairienet.org (Scott J. McCaughrin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Copy constructor
  5. Date: 12 Apr 1996 01:27:18 GMT
  6. Organization: University of Illinois at Urbana
  7. Message-ID: <4kkbhm$mva@vixen.cso.uiuc.edu>
  8. References: <4kjudi$2qj0@holly.ACNS.ColoState.EDU>
  9. Reply-To: sjmccaug@prairienet.org (Scott J. McCaughrin)
  10. NNTP-Posting-Host: firefly.prairienet.org
  11.  
  12.  
  13. In a previous article, corbyh@holly.ACNS.ColoState.EDU (Corby S. Hudnall) says:
  14.  
  15. >Hi all, I'm having some trouble figuring out how to do a copy 
  16. >constructor.  Here's what I thought was suppose to work:
  17. >
  18. >header file----
  19. >class ABC
  20. >{
  21. >    private:
  22. >        int AnInt;
  23. >
  24. >    public:
  25. >        ABC():AnInt(5) {}  // Default Constructor
  26. >        ~ABC() {}          // Default Destructor
  27. >        ABC(const ABC&);   // Copy constructor
  28. >}
  29. >
  30. >ABC::ABC(const ABC& NewABC)
  31. >{
  32. >   this->AnInt = NewABC->AnInt;
  33.  
  34.  why the ->? should be:  AAnInt = NewABC.AnInt;
  35. >}
  36. >
  37. >Unfortunatly, I can't get this to work right.  I get weird messages from 
  38. >the compiler complaining about not being able to use a class definition 
  39. >as an argument.  This was using xlC under IBM Aix.  Any suggestions are 
  40. >greatly appreciated.  Thanks.
  41. >
  42. >
  43. >          T E A R   A L O N G  T H E   D O T T E D  L I N E
  44. >- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  45. >Corby S. Hudnall                 Junior, Spring 1996
  46. >Colorado State University        http://WWW.CS.ColoState.EDU/~hudnall
  47. >Department of Computer Science   hudnall@CS.ColoState.EDU
  48. >
  49. >
  50.  
  51.